package com.example.bookstore.mapper;

import com.example.bookstore.entity.Product;
import com.example.bookstore.form.bookform.InsertBookForm;
import com.example.bookstore.form.bookform.UpdateBookForm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Mapper
@Repository
public interface ProductMapper {

    //添加图书
    Integer InsertBook(Product product);

    //编辑图书信息
    Integer UpdateBook(UpdateBookForm updateBookForm);

    //更新图书图片
    Integer UpdateBookImg(@Param("imgUrl") String imgUrl,@Param("productId") Integer productId);

    //更新图书库存
    Integer UpdateBookPnum(@Param("pnum") Integer pnum,@Param("productId") Integer productId);

    //下架图书
    Integer DeleteBook(Integer productId);

    //按id精确查询
    Product SelectBookById(Integer productId);

    //按类别查看图书
    List<Product> SelectBookByClass(String productClass);

    //按书名模糊查询图书
    List<Product> SelectBookByName(String productName);

    //随机返回10条书籍信息
    List<Product> ShowRandomBook();

    //显示所有图书
    List<Product> ShowAllBook();

}